ConsoleApplication Class

Used to run console applications on Windows, Mac OS X, and Linux.

Events

Run

UnhandledException


Properties

ExecutableFile


Methods

Daemonize

DoEvents


More information available in parent classes: Object


Notes

A console application differs from a desktop application in that it contains no graphical user interface and works only from the command line. In Mac OS X, a console application runs within the Terminal application; on Windows, it runs from the command line prompt, and on Linux it runs from the command line or a Terminal window.

To create a console application, choose File . New Project and choose Console Application from the New Project dialog box. This will create a new project without items for the default window and menubar. The Project Editor will only have the App class, which is subclassed from ConsoleApplication instead of Application.

Because a console application has no windows or menus of its own, it communicates with the user is through the Print and Input commands or the StandardInputStream and StandardOutputStream classes, which provide equivalent functionality.

When you create a GUI application, the program execution begins in the Open event of the Application class and halts when you call the Quit method or the user quits your application by choosing File . Quit. Your program will stay loaded in memory and running until a Quit command is received.

A console application behaves differently from a desktop application. The program execution begins in the Run event of the ConsoleApplication class and terminates when you exit the Run event or call the Quit method. In other words, the entire application executes inside of the Run event.

If you would like your application to behave in a more GUI-like way, where it continues to run until the user interacts with it, then you can do that by placing a While loop in the Run event.

A ServiceApplication is a special type of console application that is designed to run without user intervention of any kind. The typical type of service application is a an internet server, such as an HTTP, FTP, or WebDAV server, which is capable of running without any user logged into the machine.

On Linux, a console application does not require GTK, GDK, or CUPS.

A console application cannot use the Graphics class. This rules out the use of the Picture class, the Movie class, and all other graphics-oriented classes.

The Daemonize Method

A typical use of the Daemonize method is as follows:

If (args(1) = "start" or args(1) = "-d") then
 If Not App.Daemonize then
   System.Log( System.LogLevelCritical, "Could not daemonize the " _
           +"application")
   Return -1
  end
end

See Also

Input, Print, StdErr, StdIn, StdOut methods; ServiceApplication, StandardInputStream, StandardOutputStream classes; TargetHasGUI constant.